/* characters used to encode 6 bits */ char *pick = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; main() { char first[16],second[16],salt[3]; /* pick random salt */ srand(time(0)); salt[0]= pick[(rand()>>10)&0x2f]; salt[1]= pick[(rand()>>10)&0x2f]; salt[2]='\0'; /* not necessary */ /* get string */ strcpy(first,getpass("Password: ")); strcpy(second,getpass("Again: ")); if(strcmp(first,second)!=0) { printf("Passwords not the same both times.\n"); exit(1); } /* output */ printf("Password string: %s\n",crypt(first,salt)); return(0); }